//
//  NRWCarSubscriptionCell.m
//  New_Runway
//
//  Created by NewLife on 2018/3/16.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "NRWCarSubscriptionCell.h"

@implementation NRWCarSubscriptionCell
{
    UIImageView *deleteImgV;
    UIButton *contentBtn;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.contentView.backgroundColor = self.backgroundColor = kColorWhite();
        
        deleteImgV =
        DPImageView()
        .setImage(getImageFromName(@"sub_delete"))
        .setUserInteractionEnabled(YES);
        deleteImgV.opaque = YES;
        
        contentBtn =
        DPButton()
        .setTitleFont(kPingFangRegular13())
        .setNormalTitleColor(getColorFromString(@"ff6816"));
        [contentBtn setBackgroundImage:getImageFromName(@"btn_orange_normal") forState:UIControlStateNormal];
        
        self.contentView.addSubview(contentBtn).addSubview(deleteImgV);
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(deleteImgVDidClick:)];
        [deleteImgV addGestureRecognizer:tap];
        
        [deleteImgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top);
            make.right.equalTo(self.contentView.mas_right);
        }];
        
        [contentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView);
            make.bottom.equalTo(self.contentView.mas_bottom);
            make.top.equalTo(deleteImgV.mas_centerY);
            make.right.equalTo(deleteImgV.mas_centerX);
        }];
    }
    return self;
}

- (void)setTitleStr:(NSString *)titleStr {
    
    _titleStr = titleStr;
    
    contentBtn.setNormalTitle(titleStr);
}

- (void)deleteImgVDidClick:(UITapGestureRecognizer *)sender {
    
    if ([self.delegate respondsToSelector:@selector(subscriptionCell:deleteBtnDidClick:)]) {
        
        [self.delegate subscriptionCell:self deleteBtnDidClick:sender];
    }
}

@end
